import { createBrowserRouter, Link } from 'react-router-dom'
import App from '../App'
import {ErrorBlock} from 'antd-mobile'
const routes=createBrowserRouter([
    {
        path:'/',
        element:<App/>,
        children:[
            {
                path:'home',
                async lazy(){
                    const {default:Home,loader}= await import('../pages/home/Index')
                    return{
                        element:<Home/>,
                        loader
                    }
                }
            },
            {
                path:'todo',
                async lazy(){
                    const {default:Todo,loader}= await import('../pages/todo/Index')
                    return{
                        element:<Todo/>,
                        loader
                    }
                }
            }, {
                path:'message',
                async lazy(){
                    const {default:Message,loader}= await import('../pages/message/Index')
                    return{
                        element:<Message/>,
                        loader
                    }
                }
            }, {
                path:'my',
                async lazy(){
                    const {default:My,loader}= await import('../pages/my/Index')
                    return{
                        element:<My/>,
                        loader
                    }
                }
            },
        ]
    },
    {
        path:'list',
        async lazy(){
            const {default:List,loader}= await import('../pages/list/Index')
            return{
                element:<List/>,
                loader
            }
        }
    },
    {
        path:'xq',
        async lazy(){
            const {default:Xq,loader}= await import('../pages/xq/Index')
            return{
                element:<Xq/>,
                loader
            }
        }
    },
    {
        path:'order',
        async lazy(){
            const {default:Order,loader}= await import('../pages/order/Index')
            return{
                element:<Order/>,
                loader
            }
        }
    },
    {
        path:'add',
        async lazy(){
            const {default:Add,loader}= await import('../pages/add/Index')
            return{
                element:<Add/>,
                loader
            }
        }
    },
    {
        path:'pay',
        async lazy(){
            const {default:Pay,loader}= await import('../pages/pay/Index')
            return{
                element:<Pay/>,
                loader
            }
        }
    },
    {
        path:'success',
        async lazy(){
            const {default:Success,loader}= await import('../pages/success/Index')
            return{
                element:<Success/>,
                loader
            }
        }
    },
    {
        path:'zf',
        async lazy(){
            const {default:Zf,loader}= await import('../pages/zf/Index')
            return{
                element:<Zf/>,
                loader
            }
        }
    },
    {
        path:'*',
        element:(<ErrorBlock fullPage description={<Link to='/home'>返回首页</Link>}></ErrorBlock>)
    }
])
export default routes;